import time
from .data import load_terminateRela,baseurl
import allure
import pytest
import requests
import os



basedir=os.path.dirname(__file__)
filepath=os.path.join(basedir,"testCase/terminateRela.json")
@allure.epic("解除宜医患关系接口")
class TestTerminateRela:
    def setup_class(self):
        self.session=requests.session()
        self.url1=f"{baseurl}/login"
        self.url2 = f"{baseurl}/patients/delete/"
        print("解除宜医患关系接口测试开始：", time.strftime("%Y-%m-%d-%H:%M:%S"))
    def teardown_class(self):
        self.session.close()
        print("解除宜医患关系接口测试结束：", time.strftime("%Y-%m-%d-%H:%M:%S"))
    @pytest.mark.parametrize("testCase,login_name,login_password,username,msg,status_code",load_terminateRela(filepath))
    @allure.title("{testCase}")
    def test_terminateRela(self,testCase,login_name,login_password,username,msg,status_code):
        self.session.post(self.url1,data={"username":login_name,"password":login_password})
        responses=self.session.get(f"{self.url2}{username}")
        assert status_code==responses.status_code
        assert msg in responses.url
        self.session.cookies.clear()

